﻿using System;
using System.CodeDom.Compiler;
using Microsoft.SqlServer.Server;
using static System.Console;
namespace task4
{
    internal class Program
    { 
        public static bool[] num = new bool[666666];
        // public bool[] is_prime = new bool[100];
        public static int temp = 2;
        public static int total = 0;
        public static void eratos()//埃氏筛法
        {
            for (int i = 2; i < num.Length; i++)
            {
                num[i] = true;
            }//全初始化为是

            for (int i = 1; i < 100000; i++)
            {
                if (num[i] == true)//如果是素数
                {
                    for (int j = i * 2; j < 100000; j += i)
                    {
                        num[j] = false; //那他的倍数就全是合数
                    }
                }
            }
        }

        public static void Main(string[] args)
        {
            DateTime start=DateTime.Now;//开始运行时间
            int res = 0;
            eratos();
            for (int i = 0; i < 100000; i++)
            {
                if (num[i]==true)
                {
                    res = i;//更新结果值
                }
            }
            DateTime over=DateTime.Now;//结束运行时间
            TimeSpan time = over.Subtract(start);
            WriteLine(res);
            Write(time.Milliseconds);//跑了几毫秒
           
        }
    }
}